<?php
/**
 * Created by PhpStorm.
 * User: change
 * Date: 2017/1/4
 * Time: 9:54
 * 资讯收藏
 */

namespace Admin\Model;


use Base\Model\BaseModel;

class CollectModel extends BaseModel
{
    protected $_validate = array(
        array('user_id', 'require', '患者必须选择'),
        array('info_id', 'require', '资讯必须选择')
    );

    protected $_auto = array(
        array('status', '1'),
        array('create_time', 'time', self::MODEL_INSERT, 'function'),
        array('last_time', 'time', self::MODEL_BOTH, 'function')
    );

    protected $_link = array(
        //关联资讯
        'information' => array(
            'mapping_type' => self::BELONGS_TO,
            'foreign_key' => 'info_id',
            'parent_key' => 'id',
            'mapping_order' => 'id desc',
            'condition' => 'status=1'
        ),
        //关联患者
        'patient' => array(
            'mapping_type' => self::BELONGS_TO,
            'foreign_key' => 'user_id',
            'parent_key' => 'id',
            'condition' => 'status=1'
        )
    );
}